home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / idl / nsICryptoHash.idl < prev    next >
Text File  |  2006-05-08  |  5KB  |  138 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is mozilla.org code.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * Doug Turner <dougt@meer.net>.
  18.  * Portions created by the Initial Developer are Copyright (C) 2005
  19.  * the Initial Developer. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  *
  23.  * Alternatively, the contents of this file may be used under the terms of
  24.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  25.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  26.  * in which case the provisions of the GPL or the LGPL are applicable instead
  27.  * of those above. If you wish to allow use of your version of this file only
  28.  * under the terms of either the GPL or the LGPL, and not to allow others to
  29.  * use your version of this file under the terms of the MPL, indicate your
  30.  * decision by deleting the provisions above and replace them with the notice
  31.  * and other provisions required by the GPL or the LGPL. If you do not delete
  32.  * the provisions above, a recipient may use your version of this file under
  33.  * the terms of any one of the MPL, the GPL or the LGPL.
  34.  *
  35.  * ***** END LICENSE BLOCK ***** */
  36.  
  37. #include "nsISupports.idl"
  38. interface nsIInputStream;
  39.  
  40. /**
  41.  * nsICryptoHash
  42.  * This interface provides crytographic hashing algorithms.
  43.  */
  44.  
  45. [scriptable, uuid(1e5b7c43-4688-45ce-92e1-77ed931e3bbe)]
  46. interface nsICryptoHash : nsISupports
  47. {
  48.     /**
  49.      * Hashing Algorithms.  These values are to be used by the
  50.      * |init| method to indicate which hashing function to
  51.      * use.  These values map directly onto the values defined
  52.      * in mozilla/security/nss/lib/cryptohi/hasht.h.
  53.      */
  54.     const short MD2    = 1;  /* String value: "md2"    */
  55.     const short MD5    = 2;  /* String value: "md5"    */
  56.     const short SHA1   = 3;  /* String value: "sha1"   */
  57.     const short SHA256 = 4;  /* String value: "sha256" */
  58.     const short SHA384 = 5;  /* String value: "sha384" */
  59.     const short SHA512 = 6;  /* String value: "sha512" */
  60.  
  61.     /**
  62.      * Initialize the hashing object. This method may be
  63.      * called multiple times with different algorithm types.
  64.      *
  65.      * @param aAlgorithm the algorithm type to be used.
  66.      *        This value must be one of the above valid
  67.      *        algorithm types.
  68.      *
  69.      * @throws NS_ERROR_INVALID_ARG if an unsupported algorithm
  70.      *         type is passed.
  71.      *
  72.      * NOTE: This method or initWithString must be called
  73.      *       before any other method on this interface is called.
  74.      */
  75.     void init(in unsigned long aAlgorithm);
  76.  
  77.     /**
  78.      * Initialize the hashing object. This method may be
  79.      * called multiple times with different algorithm types.
  80.      *
  81.      * @param aAlgorithm the algorithm type to be used.
  82.      *
  83.      * @throws NS_ERROR_INVALID_ARG if an unsupported algorithm
  84.      *         type is passed.
  85.      *
  86.      * NOTE: This method or init must be called before any
  87.      *       other method on this interface is called.
  88.      */
  89.     void initWithString(in ACString aAlgorithm);
  90.   
  91.     /**
  92.      * @param aData a buffer to calculate the hash over
  93.      *
  94.      * @param aLen the length of the buffer |aData|
  95.      *
  96.      * @throws NS_ERROR_NOT_INITIALIZED if |init| has not been 
  97.      *         called.
  98.      */
  99.     void update([const, array, size_is(aLen)] in octet aData, in unsigned long aLen);
  100.  
  101.     /**
  102.      * Calculates and updates a new hash based on a given data stream.
  103.      *
  104.      * @param aStream an input stream to read from.
  105.      *
  106.      * @param aLen how much to read from the given |aStream|.  Passing
  107.      *        PR_UINT32_MAX indicates that all data available will be used 
  108.      *        to update the hash. 
  109.      *
  110.      * @throws NS_ERROR_NOT_INITIALIZED if |init| has not been 
  111.      *         called.
  112.      *
  113.      * @throws NS_ERROR_NOT_AVAILABLE if the requested amount of 
  114.      *         data to be calculated into the hash is not available.
  115.      *
  116.      */
  117.     void updateFromStream(in nsIInputStream aStream, in unsigned long aLen);
  118.     
  119.     /**
  120.      * Completes this hash object and produces the actual hash data.
  121.      *
  122.      * @param aASCII if true then the returned value is a base-64 
  123.      *        encoded string.  if false, then the returned value is
  124.      *        binary data.  
  125.      *
  126.      * @return a hash of the data that was read by this object.  This can
  127.      *         be either binary data or base 64 encoded.
  128.      *
  129.      * @throws NS_ERROR_NOT_INITIALIZED if |init| has not been 
  130.      *         called.
  131.      *
  132.      * NOTE: This method may be called any time after |init|
  133.      *       is called.  This call resets the object to its
  134.      *       pre-init state.
  135.      */
  136.     ACString finish(in PRBool aASCII);
  137. };
  138.